package com.ashok.mvc.controller;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.security.core.Authentication;
import org.springframework.security.core.context.SecurityContextHolder;
import org.springframework.stereotype.Controller;
import org.springframework.ui.ModelMap;
import org.springframework.web.bind.annotation.RequestMapping;

@Controller
@RequestMapping(value="/admin")
public class AdminController {
	private static final Logger LOGGER = LoggerFactory.getLogger(LoginController.class);
	@RequestMapping(value="/success")
	public String getSuccessPage(ModelMap model){
		Authentication auth = SecurityContextHolder.getContext().getAuthentication();
		String user = auth.getName();
		LOGGER.info(user.concat(" trying to access /admin/success.html"));
		model.addAttribute("user",user);
		return "success";
	}
	@RequestMapping(value="/profile")
	public String getProfile(){
		LOGGER.info("You are trying to access /admin/profile.html");
		return "profilepage";
	}

}
